package com.zhixiang.xaec.entity.system;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.google.gson.annotations.Expose;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "sys_app_funurl")
public class FunUrl {
	@Id
	@GenericGenerator(name = "idGenerator",strategy = "com.zhixiang.core.util.IdGenerator")
	@GeneratedValue(generator = "idGenerator")
	@Expose
	protected Long urlId;

	protected String urlPath;
	@ManyToOne(optional = true, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinColumn(name = "functionId", referencedColumnName = "functionId")
	protected AppFunction appFunction;

	public FunUrl() {
	}

	public FunUrl(String paramString) {
		this.urlPath = paramString;
	}

	public FunUrl(Long paramLong) {
		setUrlId(paramLong);
	}

	public AppFunction getAppFunction() {
		return this.appFunction;
	}

	public void setAppFunction(AppFunction paramAppFunction) {
		this.appFunction = paramAppFunction;
	}

	public Long getUrlId() {
		return this.urlId;
	}

	public void setUrlId(Long paramLong) {
		this.urlId = paramLong;
	}

	public Long getFunctionId() {
		return getAppFunction() == null ? null : getAppFunction()
				.getFunctionId();
	}

	public void setFunctionId(Long paramLong) {
		if (paramLong == null) {
			this.appFunction = null;
		} else if (this.appFunction == null) {
			this.appFunction = new AppFunction(paramLong);
		} else {
			this.appFunction.setFunctionId(paramLong);
		}
	}

	public String getUrlPath() {
		return this.urlPath;
	}

	public void setUrlPath(String paramString) {
		this.urlPath = paramString;
	}

	public boolean equals(Object paramObject) {
		if (!(paramObject instanceof FunUrl))
			return false;
		FunUrl localFunUrl = (FunUrl) paramObject;
		return new EqualsBuilder().append(this.urlId, localFunUrl.urlId)
				.append(this.urlPath, localFunUrl.urlPath).isEquals();
	}

	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973).append(this.urlId)
				.append(this.urlPath).toHashCode();
	}

	public String toString() {
		return new ToStringBuilder(this).append("urlId", this.urlId)
				.append("urlPath", this.urlPath).toString();
	}
}
